#include <bits/stdc++.h>
using namespace std;
const int MAX = 400400;

int a[MAX], s[MAX];
long long s[MAX];
int main() {
  int n, Q;
  cin >> n >> Q;
  for (int i = 1; i <= n; ++i) {
    int k;
    cin >> k;
    a[i] = a[i + n] = k; // 加倍
  }

  for (int i = 1; i <= n + n; ++i)
    s[i] = s[i - 1] + a[i];

  int head = 1;

  while (Q--) {
    int op;
    cin >> op;
    if (op == 1) {
      int x;
      cin >> x;
      head = (head + x) % n;
    } else {
      int l, r;
      cin >> l >> r;
      printf("lld\n", s[head + r] - s[head + l - 1]);
    }
    return 0;
  }
